#include <stdio.h>
#include <stdlib.h>

//https://www.nowcoder.com/practice/351b3d03e410496ab5a407b7ca3fd841?tpId=290&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D290

typedef struct Flexible {
    int N;
    int Mat[0];
}Flexible;

int main() {
    int row = 0;
    int col = 0;
    scanf("%d%d", &row, &col);
    //创建柔数
    Flexible *Arr = (Flexible *) malloc(sizeof(Flexible) + row * col * sizeof(int));
    if (Arr == NULL) {
        perror("堆区开辟空间失败:");
    }
    Arr->N = row * col;

    //使用柔数
    for (int i = 0; i < Arr->N; i++) {
        scanf("%d", Arr->Mat + i);
    }
    for (int j = 0; j < col; j++) {
        for (int i = 0; i / col < row; i += col) {
            printf("%d ", Arr->Mat[i + j]);
        }
        printf("\n");
    }

    //释放柔数
    free(Arr);
    Arr = NULL;
    return 0;
}